Passed
Push — develop ( d0052f...e203ec )
by Reüel
08:39
created

module.exports   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 540

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
c 3
b 0
f 0
nc 1
dl 0
loc 540
rs 8.2857
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
/* jshint node:true */
0 ignored issues
show
Coding Style introduced by
You must use "/**" style comments for a file comment
Loading history...
2
module.exports = function( grunt ) {
3
	require( 'load-grunt-tasks' )( grunt );
4
5
	// Project configuration.
6
	grunt.initConfig( {
7
		pkg: grunt.file.readJSON( 'package.json' ),
8
9
		// PHPLint
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
10
		phplint: {
11
			core: [
12
				'**/*.php',
13
				'!build/**',
14
				'!deploy/**',
15
				'!includes/xmlseclibs/**',
16
				'!node_modules/**',
17
				'!repositories/**',
18
				'!vendor/**',
19
				'!wp-content/**',
20
				'!wordpress/**'
21
			],
22
			wp_pay: [
23
				'vendor/wp-pay/**/*.php',
24
				'vendor/wp-pay-extensions/**/*.php',
25
				'vendor/wp-pay-gateways/**/*.php'
26
			]
27
		},
28
29
		// PHP Code Sniffer.
30
		phpcs: {
31
			core: {
32
				src: [
33
					'admin/**/*.php',
34
					'includes/**/*.php',
35
					'!includes/updates/**',
36
					'views/**/*.php',
37
					'pronamic-ideal.php',
38
					'uninstall.php'
39
				]
40
			},
41
			options: {
42
				bin: 'vendor/bin/phpcs',
43
				standard: 'phpcs.xml.dist',
44
				showSniffCodes: true
45
			}
46
		},
47
48
		// PHPUnit.
49
		phpunit: {
50
			options: {
51
				bin: 'vendor/bin/phpunit'
52
			},
53
			classes: {
54
				
55
			}
56
		},
57
58
		// JSHint.
59
		jshint: {
60
			options: grunt.file.readJSON( '.jshintrc' ),
61
			grunt: [ 'Gruntfile.js' ],
62
			plugin: [
63
				'src/js/*.js'
64
			]
65
		},
66
67
		// Sass Lint.
68
		sasslint: {
69
			options: {
70
				configFile: '.sass-lint.yml'
71
			},
72
			target: [
73
				'src/sass/**/*.scss'
74
			]
75
		},
76
		
77
		// Check textdomain errors.
78
		checktextdomain: {
79
			options:{
80
				text_domain: 'pronamic_ideal',
81
				keywords: [
82
					'__:1,2d',
83
					'_e:1,2d',
84
					'_x:1,2c,3d',
85
					'esc_html__:1,2d',
86
					'esc_html_e:1,2d',
87
					'esc_html_x:1,2c,3d',
88
					'esc_attr__:1,2d',
89
					'esc_attr_e:1,2d',
90
					'esc_attr_x:1,2c,3d',
91
					'_ex:1,2c,3d',
92
					'_n:1,2,4d',
93
					'_nx:1,2,4c,5d',
94
					'_n_noop:1,2,3d',
95
					'_nx_noop:1,2,3c,4d'
96
				]
97
			},
98
			files: {
99
				src:  [
100
					'**/*.php',
101
					'!build/**',
102
					'!deploy/**',
103
					'!node_modules/**',
104
					'!tests/**',
105
					'!wordpress/**',
106
					'!wp-content/**'
107
				],
108
				expand: true
109
			}
110
		},
111
112
		// Make POT.
113
		makepot: {
114
			target: {
115
				options: {
116
					cwd: 'deploy/latest',
117
					domainPath: 'languages',
118
					type: 'wp-plugin',
119
					mainFile: 'pronamic-ideal.php',
120
					exclude: [ 'vendor/pronamic/.*' ],
121
					updatePoFiles: true,
122
					updateTimestamp: false
123
				}
124
			}
125
		},
126
127
		// Imagemin.
128
		imagemin: {
129
			build: {
130
				files: [
131
					{ // Images
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
132
						expand: true,
133
						cwd: 'src/images/',
134
						src: ['**/*.{png,jpg,gif,svg,ico}'],
135
						dest: 'images/'
136
					}
137
				]
138
			}
139
		},
140
141
		// Shell.
142
		shell: {
143
			// Check versions.
144
			check_versions: {
145
				command: 'php src/check-versions.php'
146
			},
147
148
			// PlantUML.
149
			plantuml: {
150
				command: 'plantuml ./documentation/*.plantuml'
151
			},
152
153
			// WordPress test environment.
154
			test: {
155
				command: 'bash tests/setup.sh'
156
			},
157
158
			// Generate readme.txt.
159
			readme_txt: {
160
				command: 'php src/readme-txt/readme.php > readme.txt'
161
			},
162
163
			// Generate README.md.
164
			readme_md: {
165
				command: 'php src/readme-md/README.php > README.md'
166
			},
167
168
			// Generate CHANGELOG.md.
169
			changelog_md: {
170
				command: 'php src/changelog-md/CHANGELOG.php > CHANGELOG.md'
171
			},
172
173
			// Composer.
174
			deploy: {
175
				command: [
176
					'cd deploy/latest',
177
					'composer install --no-dev --prefer-dist'
178
				].join( '&&' )
179
			}
180
		},
181
182
		// Copy.
183
		copy: {
184
			scripts: {
185
				files: [
186
					{ // JS.
187
						expand: true,
188
						cwd: 'src/js/',
189
						src: '**',
190
						dest: 'js/'
191
					}
192
				]
193
			},
194
			assets: {
195
				files: [
196
					{ // Flot - http://www.flotcharts.org/.
197
						expand: true,
198
						cwd: 'node_modules/flot/',
199
						src: [
200
							'jquery.flot.js',
201
							'jquery.flot.time.js',
202
							'jquery.flot.resize.js'
203
						],
204
						dest: 'assets/flot'
205
					},
206
					{ // accounting.js - http://openexchangerates.github.io/accounting.js/.
207
						expand: true,
208
						cwd: 'node_modules/accounting/',
209
						src: 'accounting.js',
210
						dest: 'assets/accounting'
211
					},
212
					{ // Tippy.js - https://atomiks.github.io/tippyjs/.
213
						expand: true,
214
						cwd: 'node_modules/tippy.js/dist',
215
						src: 'tippy.all.js',
216
						dest: 'assets/tippy.js'
217
					}
218
				]
219
			},
220
			other: {
221
				files: [
222
					{ // extensions.json.
223
						expand: true,
224
						cwd: 'src/',
225
						src: [
226
							'extensions.json'
227
						],
228
						dest: 'other/'
229
					}
230
				]
231
			},
232
			deploy: {
233
				expand: true,
234
				src: [
235
					'**',
236
					'!composer.lock',
237
					'!Gruntfile.js',
238
					'!package.json',
239
					'!package-lock.json',
240
					'!phpdoc.dist.xml',
241
					'!phpunit.xml',
242
					'!phpunit.xml.dist',
243
					'!phpcs.xml.dist',
244
					'!CHANGELOG.md',
245
					'!README.md',
246
					'!yarn.lock',
247
					'!build/**',
248
					'!deploy/**',
249
					'!etc/**',
250
					'!documentation/**',
251
					'!node_modules/**',
252
					'!repositories/**',
253
					'!src/**',
254
					'!tests/**',
255
					'!vendor/**',
256
					'!wordpress/**',
257
					'!wp-content/**'
258
				],
259
				dest: 'deploy/latest/'
260
			},
261
			pot_to_dev: {
262
				expand: true,
263
				cwd: 'deploy/latest/languages/',
264
				src: '**',
265
				dest: 'languages/'
266
			}
267
		},
268
269
		// Composer.
270
		composer : {
271
			options : {
272
273
			},
274
			some_target: {
275
            	options : {
276
                	cwd: 'deploy/latest'
277
				}
278
			}
279
		},
280
281
		// SASS.
282
		sass: {
283
			options: {
284
				style: 'expanded'
285
			},
286
			build: {
287
				files: [ {
288
					expand: true,
289
					cwd: 'src/sass',
290
					src: '*.scss',
291
					dest: 'src/css',
292
					ext: '.css'
293
				} ]
294
			}
295
		},
296
297
		// PostCSS.
298
		postcss: {
299
			options: {
300
				map: false
301
			},
302
			prefix: {
303
				options: {
304
					processors: [
305
						require( 'autoprefixer' )(),
306
						require( 'postcss-eol' )()
307
					]
308
				},
309
				files: [ {
310
					expand: true,
311
					cwd: 'src/css/',
312
					src: '*.css',
313
					dest: 'css/'
314
				} ]
315
			},
316
			min: {
317
				options: {
318
					processors: [
319
						require( 'cssnano' )(),
320
						require( 'postcss-eol' )()
321
					]
322
				},
323
				files: [ {
324
					expand: true,
325
					cwd: 'css/',
326
					src: [
327
						'*.css',
328
						'!*.min.css'
329
					],
330
					dest: 'css/',
331
					ext: '.min.css'
332
				} ]
333
			}
334
		},
335
336
		// Uglify.
337
		uglify: {
338
			scripts: {
339
				files: {
340
					// Pronamic Pay.
341
					'js/admin.min.js': 'src/js/admin.js',
342
					'js/admin-reports.min.js': 'src/js/admin-reports.js',
343
					'js/admin-tour.min.js': 'src/js/admin-tour.js',
344
					// Accounting.
345
					'assets/accounting/accounting.min.js': 'assets/accounting/accounting.js',
346
					// Flot.
347
					'assets/flot/jquery.flot.min.js': 'assets/flot/jquery.flot.js',
348
					'assets/flot/jquery.flot.resize.min.js': 'assets/flot/jquery.flot.resize.js',
349
					'assets/flot/jquery.flot.time.min.js': 'assets/flot/jquery.flot.time.js',
350
					// Tippy.js.
351
					'assets/tippy.js/tippy.all.min.js': 'assets/tippy.js/tippy.all.js'
352
				}
353
			}
354
		},
355
356
		// Clean.
357
		clean: {
358
			assets: {
359
				src: [
360
					'assets',
361
					'css',
362
					'images',
363
					'js'
364
				]
365
			},
366
			deploy: {
367
				src: [ 'deploy/latest' ]
368
			},
369
			deploy_composer: {
370
				src: [
371
					'deploy/latest/vendor/pronamic/*/bin/**',
372
					'deploy/latest/vendor/pronamic/*/documentation',
373
					'deploy/latest/vendor/pronamic/*/test/**',
374
					'deploy/latest/vendor/pronamic/*/tests/**',
375
					'deploy/latest/vendor/pronamic/*/.gitignore',
376
					'deploy/latest/vendor/pronamic/*/.travis.yml',
377
					'deploy/latest/vendor/pronamic/*/Gruntfile.js',
378
					'deploy/latest/vendor/pronamic/*/package.json',
379
					'deploy/latest/vendor/pronamic/*/package-lock.json',
380
					'deploy/latest/vendor/pronamic/*/phpcs.ruleset.xml',
381
					'deploy/latest/vendor/pronamic/*/phpcs.xml.dist',
382
					'deploy/latest/vendor/pronamic/*/phpmd.ruleset.xml',
383
					'deploy/latest/vendor/pronamic/*/phpunit.xml.dist',
384
					'deploy/latest/vendor/wp-pay*/*/bin/**',
385
					'deploy/latest/vendor/wp-pay*/*/documentation',
386
					'deploy/latest/vendor/wp-pay*/*/test/**',
387
					'deploy/latest/vendor/wp-pay*/*/tests/**',
388
					'deploy/latest/vendor/wp-pay*/*/.gitignore',
389
					'deploy/latest/vendor/wp-pay*/*/.travis.yml',
390
					'deploy/latest/vendor/wp-pay*/*/Gruntfile.js',
391
					'deploy/latest/vendor/wp-pay*/*/package.json',
392
					'deploy/latest/vendor/wp-pay*/*/package-lock.json',
393
					'deploy/latest/vendor/wp-pay*/*/phpcs.ruleset.xml',
394
					'deploy/latest/vendor/wp-pay*/*/phpcs.xml.dist',
395
					'deploy/latest/vendor/wp-pay*/*/phpmd.ruleset.xml',
396
					'deploy/latest/vendor/wp-pay*/*/phpunit.xml.dist'
397
				]
398
			},
399
			deploy_wp_content: {
400
				src: [
401
					'deploy/latest/wp-content'
402
				]
403
			}
404
		},
405
406
		// Compress.
407
		compress: {
408
			deploy: {
409
				options: {
410
					archive: 'deploy/archives/<%= pkg.name %>.<%= pkg.version %>.zip'
411
				},
412
				expand: true,
413
				cwd: 'deploy/latest',
414
				src: ['**/*'],
415
				dest: '<%= pkg.name %>/'
416
			}
417
		},
418
419
		// Git checkout.
420
		gitcheckout: {
421
			tag: {
422
				options: {
423
					branch: 'tags/<%= pkg.version %>'
424
				}
425
			},
426
			develop: {
427
				options: {
428
					branch: 'develop'
429
				}
430
			}
431
		},
432
433
		// S3.
434
		aws_s3: {
435
			options: {
436
				region: 'eu-central-1'
437
			},
438
			deploy: {
439
				options: {
440
					bucket: 'downloads.pronamic.eu',
441
					differential: true
442
				},
443
				files: [
444
					{
445
						expand: true,
446
						cwd: 'deploy/archives/',
447
						src: '<%= pkg.name %>.<%= pkg.version %>.zip',
448
						dest: 'plugins/<%= pkg.name %>/'
449
					}
450
				]
451
			}
452
		},
453
		
454
		// WordPress deploy.
455
		rt_wp_deploy: {
456
			app: {
457
				options: {
458
					svnUrl: 'http://plugins.svn.wordpress.org/<%= pkg.name %>/',
459
					svnDir: 'deploy/wp-svn',
460
					svnUsername: 'pronamic',
461
					deployDir: 'deploy/latest',
462
					version: '<%= pkg.version %>'
463
				}
464
			}
465
		},
466
467
		webfont: {
468
			icons: {
469
				src: 'src/fonts/images/*.svg',
470
				dest: 'fonts',
471
				options: {
472
					font: 'pronamic-pay-icons',
473
					fontFamilyName: 'Pronamic Pay Icons',
474
					normalize: true,
475
					stylesheets: [ 'css' ],
476
					templateOptions: {
477
						baseClass: 'pronamic-pay-icon',
478
						classPrefix: 'pronamic-pay-icon-'
479
					},
480
					types: [ 'eot', 'woff2', 'woff', 'ttf', 'svg' ],
481
					fontHeight: 768,
482
					customOutputs: [ {
483
						template: 'src/fonts/templates/variables.scss',
484
						dest: 'src/fonts/_variables.scss'
485
					} ]
486
				}
487
			}
488
		}
489
	} );
490
491
	// Default task(s).
492
	grunt.registerTask( 'default', [ 'jshint', 'phplint', 'phpcs', 'phpunit', 'shell:check_versions' ] );
493
	grunt.registerTask( 'assets', [ 'sasslint', 'sass', 'postcss', 'copy:scripts', 'copy:assets', 'copy:other' ] );
494
	grunt.registerTask( 'min', [ 'uglify', 'imagemin' ] );
495
	grunt.registerTask( 'plantuml', [ 'shell:plantuml' ] );
496
	grunt.registerTask( 'pot', [ 'build_latest', 'makepot', 'copy:pot_to_dev' ] );
497
498
	grunt.registerTask( 'build_docs', [
499
		'shell:readme_txt',
500
		'shell:readme_md',
501
		'shell:changelog_md'
502
	] );
503
504
	grunt.registerTask( 'build_assets', [
505
		'clean:assets',
506
		'assets',
507
		'min'
508
	] );
509
510
	grunt.registerTask( 'build_latest', [
511
		'clean:deploy',
512
		'copy:deploy',
513
		'shell:deploy',
514
		'clean:deploy_composer',
515
		'clean:deploy_wp_content'
516
	] );
517
518
	grunt.registerTask( 'deploy', [
519
		'default',
520
		'build_docs',
521
		'build_assets',
522
		'build_latest',
523
		'makepot',
524
		'copy:pot_to_dev',
525
		'compress:deploy'
526
	] );
527
528
	grunt.registerTask( 'wp-deploy', [
529
		'gitcheckout:tag',
530
		'deploy',
531
		'rt_wp_deploy',
532
		'gitcheckout:develop'
533
	] );
534
	
535
	grunt.registerTask( 's3-deploy', [
536
		'gitcheckout:tag',
537
		'deploy',
538
		'aws_s3:deploy',
539
		'gitcheckout:develop'
540
	] );
541
};
542